package common;

import java.io.Serializable;

/**
 * Message skeleton
 * 
 * @author Lukasz
 *
 */

public class ControlMessage implements Serializable {

	private static final long serialVersionUID = -4001063516563993337L;
	
	private static int newId = 0;
	
	private final MessageType type;
	private final int id;
	private final boolean success;
	
	public ControlMessage(MessageType type, boolean success) {
		this.type = type;
		this.id = generateId();
		this.success = success;
	}
	
	public ControlMessage(MessageType type) {
		this(type, false);
	}
	
	public ControlMessage(ControlMessage msg, boolean success) {
		this(msg.getType(), success);
	}
	
	public MessageType getType() {
		return type;
	}
	
	public int getId() {
		return id;
	}
	
	public boolean getSuccess() {
		return success;
	}
	
	public static synchronized int generateId() {
		return newId++;
	}
	
}
